home *** CD-ROM | disk | FTP | other *** search
- Path: news.th-darmstadt.de!news
- From: Enno Sandner <enno@intellektik.informatik.th-darmstadt.de>
- Newsgroups: comp.lang.c++
- Subject: Re: When to use "->" vs "." when calling Member functions
- Date: Thu, 18 Jan 1996 11:33:16 +0100
- Organization: Fachbereich Informatik, TH Darmstadt
- Message-ID: <30FE21EC.15FB7483@intellektik.informatik.th-darmstadt.de>
- References: <4dhea1$6v8@ornews.intel.com> <30FCB569.41C67EA6@intellektik.informatik.th-darmstadt.de> <4djv40$jpa@epx.cis.umn.edu>
- NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b5 (X11; I; SunOS 4.1.3 sun4m)
-
- Dongxiao Yue wrote:
- >
- > Enno Sandner <enno@intellektik.informatik.th-darmstadt.de> writes:
- >
- > >Thurman Miller wrote:
- > >>
- > >> I'm confused, so please no harsh remarks :)
- > >>
- > >> If I've got:
- > >>
- > >> class Cfoo
- > >> {
- > >> something * getptr();
- > >> somethingelse* m_other;
- > >> }
- > >>
- > >> something * foo::getptr()
- > >> {
- > >> return m_other;
- > >> }
- > >>
- > >> Now...if I'm in another class....
- > >>
- > >> Cfoo foo;
- > >> somethingelse* = foo.getptr();
- > >>
- > >> why doesn't the following work?
- > >>
- > >> somethingelse* = foo->getptr();
- > >>
- > >> I get compile error about no "->" overloaded operator....
- > >>
- > >> Can someone point out the obvious when I use one notation over
- > >> another?
- > >>
- >
- > >If you want to use 'foo.f' where 'f' is some member of a class,
- > >'foo' must be an instance or reference to that class. If 'foo'
- > >is a pointer to a class you must use 'foo->f' to access the member 'f'.
- >
- > > Enno
- >
- > When you see foo->f, foo may not be a pointer.
-
- That's right. I only said _if_ 'foo' is a pointer to a class you must
- use operator '->' not the opposite direction ;-)
- So, I guess your remark was intended to be an addition, not a
- correction.
-
- Enno
-
-
- Enno
-